import type { App } from "vue";
import { useUserInfoStore } from "@/stores/userInfo";
import { storeToRefs } from "pinia";

const userInfoStore = useUserInfoStore();
const { buttons } = storeToRefs(userInfoStore);
// 校验按钮权限自定义指令
export const btnAuth = (app: App) => {
  app.directive("btn-roles", {
    mounted(el: HTMLElement, { value }) {
      if (!userInfoStore.buttons.includes(value)) {
        el.remove();
      }
    },
  });
};
